-
Notifications
You must be signed in to change notification settings - Fork 515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BUG: Fix subject hierarchy table showing nodes removed during batch processing #6394
Conversation
LGTM, but I think @cpinter should have a look. |
Thanks for working on this @jamesobutler ! I'm not opposed to removing this function if it's really not necessary, but having a way to soft update SH still seems like a good idea. Out of curiosity: have you tried improving the update function to remove these items? Have you noticed a decrease in the other SH related error messages after your change? Unfortunately there are still some, like about item ID mismatch, cache inconsistency etc. |
@cpinter I have attempted this, but the subject hierarchy code has been pretty confusing for me to understand between all the item terminology. Do you have any thoughts how to access these items where are no longer in the subject hierarchy node, but are persisting in the model of the various table views observing the subject hierarchy? For example the following where I remove all items in the subject hierarchy after exiting batch process state, still results in items in the table view. This when still using the slicer.util.selectModule("Data")
first = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "First")
second = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "Second")
third = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "Third")
slicer.mrmlScene.StartState(slicer.mrmlScene.BatchProcessState)
for node in [third, second]:
slicer.mrmlScene.RemoveNode(node)
slicer.mrmlScene.EndState(slicer.mrmlScene.BatchProcessState)
fourth = slicer.mrmlScene.AddNewNodeByClass("vtkMRMLMarkupsFiducialNode", "Fourth")
shNode = slicer.mrmlScene.GetSubjectHierarchyNode()
shNode.RemoveAllItems() |
@cpinter I could keep Slicer/Modules/Loadable/SubjectHierarchy/Widgets/qMRMLSubjectHierarchyModel.cxx Lines 1521 to 1527 in d24cd5b
Slicer/Modules/Loadable/SubjectHierarchy/Widgets/qMRMLSubjectHierarchyModel.cxx Lines 1553 to 1560 in d24cd5b
|
Are you familiar with Qt's model/view architecture? If not, then either start from there (and then find the Qt model items corresponding to non-existent SH items and remove them from the Qt model), or consider this issue done.
Yes, but the whole point of batch processing is to postpone these updates until the end so that the processing itself is fast when you know that many objects are to be processed. Btw I don't see images uploaded in GitHub comments for around two days now. Hopefully it will be fixed, otherwise it will be hard to follow discussions without seeing the illustrations... |
I'm not sure what is going on your end with the pictures. The pictures are rendering successfully for me on GitHub in my browser and on my mobile device. Currently I have limited time with this improvement so if removing of |
Sorry this has fallen through the cracks. I'm OK with integrating this. My only problem is that I'm not completely sure what other consequences it will have that we rebuild the hierarchy from scratch - haven't had the time to do thorough testing. I guess we can integrate this and see if it causes problems. If it does it will occur quickly because we all use SH to overview and handle the loaded data. |
@jamesobutler @lassoan If you don't see any issues please go ahead with integration whenever appropriate. |
067f600
to
d7fa0c6
Compare
d7fa0c6
to
608b98c
Compare
Originally reported at https://discourse.slicer.org/t/optimizing-performance-of-events-when-clearing-nodes/23588/9.
Code to replicate original issue
After running the above code:
I have removed
updateFromSubjectHierarchy
because of it's single usage in Slicer core being removed. This could be reverted if it is desired even though it is code not being used by core.onMRMLSceneEndBatchProcess
was switched to using the fullrebuildFromSubjectHierarchy
as when removing nodes during batch processing it was not removing them from the widget when batch processing state was ended.When using Slicer 5.1.0-2022-05-24 and the subject hierarchy widget not updating it would produce many errors of the following when the batch processing state was ended: